/** * WP Editor Jornal — ajuste do número do "olho" (front-end). * * O bloco tem largura fixa. Este script mede a largura real do texto de * .important-data__value e define o font-size para que ele preencha essa * largura em UMA linha — o que o CSS sozinho não faz (o tamanho da fonte * não conhece a quantidade de caracteres). */ ( function () { 'use strict'; // Teto de segurança (px) para valores muito curtos ("42") não ficarem // desproporcionais. Aumente/remova conforme o gosto. var MAX_PX = 200; function fit( el ) { var box = el.parentElement; if ( ! box ) { return; } el.style.whiteSpace = 'nowrap'; el.style.fontSize = '100px'; var target = box.clientWidth; var natural = el.scrollWidth; if ( target <= 0 || natural <= 0 ) { el.style.fontSize = ''; return; } var size = Math.min( MAX_PX, 100 * ( target / natural ) ); el.style.fontSize = size + 'px'; // Correção de arredondamento/subpixel. if ( el.scrollWidth > target ) { el.style.fontSize = ( size * ( target / el.scrollWidth ) ) + 'px'; } } function fitAll() { var list = document.querySelectorAll( '.important-data__value' ); for ( var i = 0; i < list.length; i++ ) { fit( list[ i ] ); } } if ( document.readyState === 'loading' ) { document.addEventListener( 'DOMContentLoaded', fitAll ); } else { fitAll(); } // Refaz quando a fonte real termina de carregar (a métrica muda). if ( document.fonts && document.fonts.ready && document.fonts.ready.then ) { document.fonts.ready.then( fitAll ); } window.addEventListener( 'load', fitAll ); } )();